package config;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.guava.framework.Router;

import freemarker.template.Configuration;

public class FreemarkerHelp{
	private static FreemarkerHelp INSTANCE;
	public static ServletContext servletContext;
	private static Configuration ctg;

	private FreemarkerHelp() {
		ctg=new Configuration();
		ctg.setServletContextForTemplateLoading(servletContext,"／");
		ctg.setTemplateUpdateDelay(0);
	}

	public static void setInstance(ServletContext sContext,Router r) {
		
		if (INSTANCE == null) {
			servletContext = sContext;
			INSTANCE = new FreemarkerHelp();
		}
	}

	public static Configuration getFreemarker() {
		if (INSTANCE == null) {
			INSTANCE = new FreemarkerHelp();
		}
		return ctg;
	}
}
